package com.kook.ball.util;
import java.net.*; 
import java.io.*; 
import java.util.Properties;
import com.kook.ball.configure.Config;


public class SendSms {

	//private static String URL = Config.getURL();
	private String URL;
	private String password;


	public SendSms(String url, String password) throws IOException{
		this.URL = url;
		this.password = password;
	}
	public boolean SetProvider(String phonenumber,String text) {
		int c; 
		try {
			String smsurl = String.format("%s/sendsms?phone=%s&text=%s&password=%s",URL, phonenumber, URLEncoder.encode(text), password);
			URL hp = new URL(smsurl);
			URLConnection hpCon = hp.openConnection();
			InputStream input = hpCon.getInputStream();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		
		
		return false;
		
	}
	
	
	
	public void Send(String phonenumber,String text) throws Exception { 
		int c; 
		URL hp;
		String smsurl = String.format("%s/sendsms?phone=%s&text=%s&password=%s",URL, phonenumber, text,password);
		hp = new URL(smsurl);
		URLConnection hpCon = hp.openConnection(); 
		int len = hpCon.getContentLength(); 
		 
		if (len > 0) { 
		 
		InputStream input = hpCon.getInputStream(); 
		int i = len; 
		while (((c = input.read()) != -1) && (i > 0)) { 
		System.out.print((char) c); 
		} 
		input.close(); 
		} else { 
		System.out.println("No Content Available"); 
		} 
		} 
	

}
